﻿using System;

namespace PasswordProvider.ViewModel.Framework
{
    public class ToggleViewModel : VisualViewModel
    {
        internal event ValueChangedEventHandler<bool> IsCheckedChanged;

        #region Construction

        internal ToggleViewModel()
        { }

        internal ToggleViewModel(string displayName, string toolTip)
            : base(displayName, toolTip)
        { }

        internal ToggleViewModel(string displayName, string toolTip, bool isChecked)
            : base(displayName, toolTip)        
        {
            _isChecked = isChecked;
        }
        internal ToggleViewModel(string displayName, string toolTip, bool isChecked, bool isEnabled)
            : base(displayName, toolTip, isEnabled)
        {
            _isChecked = isChecked; ;
        }


        #endregion

        #region Properties
        /// <summary>
        /// Get, set the IsChecked state of a toggle button.
        /// </summary>
        public bool IsChecked
        {
            get { return _isChecked; }
            set 
            {
                if (base.SetPropertyValue(value, ref _isChecked, "IsChecked"))
                {
                    if (IsCheckedChanged != null)
                        IsCheckedChanged(_isChecked);
                }

            }
        } private bool _isChecked;

        #endregion
    }
}
